<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../css/index.css" />
		<link rel="stylesheet" href="../css/page_3.css" />
	</head>

	<body>
		<!--下拉刷新容器-->
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<!--数据列表-->
				<ul class="mui-table-view">
					<li class="mui-table-view-cell" v-for="item in jsonData" v-gesture:tap.stop.prevent="change($index)">
						<a class="mui-navigate-right">
							<div class="list-content">
								<h5 class="ellipsis">{{item.B_name}}</h5>
								<i class="line"></i>
								<div class="info">
									<span class="ellipsis">
			                  			跟单人：{{item.B_documentaryName}}
			                  		</span>
								</div>
								<span class="ellipsis msg">跟单人职责:{{item.B_documentaryneed}}</span>
							</div>
						</a>
					</li>
				</ul>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script type="text/javascript" src="../../js/vue.js"></script>
		<script type="text/javascript" src="../../lease/js/vue-gesture.js"></script>
		<script type="text/javascript" src="../../js/evalHttp.js"></script>
		<script>
			mui(".mui-table-view")[0].style.display = "none";
			var app = {
				datas: {
					vm: null,
					data: {
						jsonData: []
					},
					params: {},
					changeIndex: 0,
					isDown: false
				},
				methods: {
					change: function(index) {
						var items = app.datas.data.jsonData[index];
						app.datas.changeIndex = index;
						app.methods._HTTP_GET_DATA_OPEN(items.ID);
					},
					_HTTP_CB_LISTENER: function(isOk, data) {
						mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
						mui('#pullrefresh').pullRefresh().endPullupToRefresh();
						if(isOk) {
							if(data.state == 1) {
								mui(".mui-table-view")[0].style.display = "block";
								if(data.data.length > 0) {
									var arr = app.datas.data.jsonData;
									if(app.datas.isDown) {
										app.datas.data.jsonData = data.data;
									} else {
										app.datas.data.jsonData = arr.concat(data.data);
									}
								} else {
									mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
									app.datas.params.page -= 1;
									plus.nativeUI.toast("没有更多数据了");
								}
							} else {
								plus.nativeUI.toast(data.msg);
							}
						} else {
							plus.nativeUI.alert("网络错误，请检查您的网络！");
						}
					},
					pullupRefresh: function() {
						app.datas.isDown = false;
						app.datas.params.page++;
						Xeval.Http(Xeval.Mode.HTTP_ART_GET_PD, app.datas.params, app.methods._HTTP_CB_LISTENER);
					},
					pulldownRefresh: function() {
						app.datas.isDown = true;
						app.datas.params.page = 1;
						Xeval.Http(Xeval.Mode.HTTP_ART_GET_PD, app.datas.params, app.methods._HTTP_CB_LISTENER);
					},
					_HTTP_CB_UPDATA: function(isOk, data) {
						if(isOk) {
							if(data.state > 0 || data.state < 4) {
								app.datas.data.jsonData[app.datas.changeIndex].B_status = data.state;
							} else {
								plus.nativeUI.alert(data.msg);
							}
						}
					},
					_HTTP_GET_DATA_OPEN: function(id) {
						app.datas.params.ID = id;
						Xeval.Http(Xeval.Mode.HTTP_ART_GET_SJ_BYID, app.datas.params, function(isOk, data) {
							if(isOk) {
								if(data.state == 1) {
									data.data.gdr = "加载中...";
									mui.openWindow({
										url: "c_page_3.html",
										id: "c_page_3.html",
										extras: {
											data: data.data
										}
									})
								} else {
									plus.nativeUI.toast(data.msg);
								}
							} else {
								plus.nativeUI.alert("网络错误，请检查您的网络环境！");
							}
						});

					},
					search: function() {
						var data = JSON.parse(localStorage.getItem("search"));
						localStorage.setItem("search", null);
						app.utils.getToken();
						for(var item in data) {
							var　 value = data[item];
							if(value != "") {
								app.datas.params[item] = value;
							}
						}
						app.methods.pulldownRefresh();

					}
				},
				utils: {
					getToken: function() {
						const jsonData = JSON.parse(localStorage.getItem("art_user"));
						app.datas.params = {
							Username: jsonData.data.T_accountnumber,
							Token: jsonData.guid,
							UserID: jsonData.data.T_UserID,
							page: 0,
							rows: 6
						}
					}
				},
				init: function() {
					app.datas.vm = new Vue({
						el: ".mui-table-view",
						data: app.datas.data,
						methods: app.methods
					})
					app.utils.getToken();
					app.methods.pullupRefresh();
				}
			}
			mui.plusReady(function() {
				Xeval.setUrl(Xeval.UrlModel.CRM)
				app.init();
			})
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					up: {
						callback: app.methods.pullupRefresh
					},
					down: {
						callback: app.methods.pulldownRefresh
					}
				}
			});
		</script>
	</body>

</html>